<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件委托</title>
    <style>
        li {
            list-style: none;
            display: block;
            width: 300px;
            height: 30px;
            text-align: left;
            font-size: 16px;
            line-height: 30px;
            background-color: #fedcba;
        }
        
        .over {
            width: 600px;
            height: 60px;
            line-height: 60px;
            font-size: 30px;
            background-color: #abcdef;
        }
        
        .out {
            width: 300px;
            height: 30px;
            line-height: 30px;
            font-size: 16px;
            background-color: #fedcba;
        }
    </style>
</head>

<body>
    <ul id="u01">
        <li>李昊哲</li>
        <li>刘晓兰</li>
    </ul>
    <ul id="u02">
        <li>phoenix</li>
        <li>小兰兰</li>
    </ul>
</body>

</html>
<script>
    let u01 = window.document.querySelector('#u01');
    for (let index = 0; index < u01.childElementCount; index++) {
        const element = u01.children[index];
        element.addEventListener('mouseover', function(param) {
            element.className = 'over';
        });
        element.addEventListener('mouseout', function(param) {
            element.className = 'out';
        });
    }
    let u02 = window.document.querySelector('#u02');
    u02.addEventListener('mouseover', function(e) {
        e.target.className = 'over';
    });
    u02.addEventListener('mouseout', function(e) {
        e.target.className = 'out';
    });
</script>